<template>
	<view class="u-skeleton">
		<view>
			<view class="myheader">
				<view class="myheader_help"></view> 
				<view class="myheader_opacity"></view>
			</view>
			<view class="myheader_next"></view>
			<view class="myheader_float">
				<view class="myheader_piccontain">
					<view class="wqvue-image headepic">
						<!-- <image :src="user.avatar" mode="widthFix"></image> -->
						<cos-avatar :src="user.avatar" :showSex="false" :sexIcon="user.gender_label" mode='square' size="bigLarge"></cos-avatar>
					</view> 
					<view class="myheader_sex_conatin">
						<u-icon v-if="user.gender==1" name="man" size='40' color='#3898F8'></u-icon>
						<u-icon v-else-if="user.gender==2" name="woman" size='40' color='#F1665D'></u-icon>
					</view> 
					<!-- <view class="myheader_level">
						<text class="myheaderlevelstart">Lv1</text>
						<text class="gradename">已认证</text>
					</view> -->
					<!-- <view class="myheader_level">
						<text class="myheaderlevelstart">Lv1</text>
						<text class="gradename">{{user.identity_label}}</text>
					</view> -->
				</view> 
				<view class="myheader_info">
					<view class="myheader_name d-flex align-items-center">
						<text class="myheader_name_text mr-10">{{user.nickname}}</text>
						<view class="tag-box d-flex" v-if="user.is_guaranty==1||user.is_cert==1">
							<view v-if="user.is_guaranty==1" class="tag tag-guaranty"><u-icon name='rmb' color="#ffffff" size='22'></u-icon>已担保</view>
							<view v-if="user.is_cert==1" class="tag tag-cert"><u-icon name='account-fill' color="#ffffff" size='22'></u-icon>已认证</view>
						</view>
					</view> 
					<view class="myheader_power">
						<text class="myheaderfocusnum mr-10" v-if="user.city || user.province">{{user.city || user.province}} |</text> 
						<text class="myheaderfansnum mr-10">{{user.identity_label}}</text>
						<!-- <text class="myheaderline"></text> 
						<text class="myheaderfansnum">164cm 45kg</text> -->
					</view> 
					<view class="myheader_signature" v-if="user.intro">{{user.intro}}</view>
				</view> 
				<!-- <view class="myheader_contactbtn">约拍{{user.gender==1?'他':'她'}}</view> -->
				<view class="myheader_focusbtn">关注</view> 
				<view class="myheader_tab">
					<view class="myheader_tabchild">
						<view class="myheadertabnum">{{user.orders}}</view> 
						<view class="myheadertabname">接单</view> 
						<text class="line"></text>
					</view>
					<view class="myheader_tabchild">
						<view class="myheadertabnum">{{user.thumbs}}</view> 
						<view class="myheadertabname">点赞</view> 
						<text class="line"></text>
					</view>
					<view class="myheader_tabchild">
						<view class="myheadertabnum">{{user.fans}}</view> 
						<view class="myheadertabname">粉丝</view> 
						<text class="line"></text>
					</view>
				</view>
			</view>
		</view>
		
		<!-- tab -->
		<u-sticky>
		<view class="tab-box u-skeleton-fillet">
			<u-tabs bg-color="#ffffff" inactive-color="#999" name="tab_name" :list="tabs" active-color="#616161"
				:is-scroll="false" :current="current" @change="tabChange"></u-tabs>
		</view>
		</u-sticky>
		<view class='p-20'>
			<!-- 约拍 -->
			<view v-show="current == 0">
				<post-list :isShowUser="false" type='shoot' :list="postShootList" :loadStatus="loadStatus1"></post-list>
			</view>
			<!-- 相册 -->
			<view v-show="current == 1">
				<post-list :isShowUser="false" type='album' :list="postAlbumList" :loadStatus="loadStatus2"></post-list>
			</view>
			<!-- 通告 -->
			<!-- <view v-show="current == 2">
				<post-task-list :list="postTaskList" :loadStatus="loadStatus3"></post-task-list>
			</view> -->
		</view>
		<!--骨架屏-->
		<u-skeleton :loading="loading" :animation="true" bgColor="#FFF"></u-skeleton>
	</view>
</template>

<script>
	import {mapState, mapMutations } from 'vuex'
	import postList from '../../components/post-list/post-list.vue';
	export default {
		components: {
			postList
		},
		data() {
			return {
				loading:true,
				tabs: [{
						tab_name: '约拍'
					},{
						tab_name: '相册'
					}
				],
				current: 0,
				uuid: "",
				user: {},
				postShootList:[],
				postAlbumList:[],
				loadStatus1: "loading",
				loadStatus2: "loading",
				page1: 1,
				page2: 1,
			};
		},
		computed:{
			...mapState(['hasLogin', 'userInfo']),
		},
		onLoad(options) {
			this.nav  = options.nav?options.nav:0;
			this.uuid = options.uuid;
			if(this.uuid==this.userInfo.uuid) {
				this.isShowUser = false;
			}else {
				this.isShowUser = true;
			}
			
			this.current = this.nav;
			this.getUserInfo();
			
			 if(this.nav==0) {
				this.getShootList();
			}else if(this.nav==1) {
				this.getAlbumList();
			}
		},
		onReachBottom() {
			if(this.current==0) {
				if(this.loadStatus1!='nomore') {
					this.page1++;
					this.getShootList();
				}
			}else if(this.current==1) {
				if(this.loadStatus2!='nomore') {
					this.page2++;
					this.getAlbumList();
				}
			}
		},
		methods: {
			tabChange(index) {
				this.current = index;
				if (index === 0) {
					if(this.postShootList.length==0&&this.loadStatus1!='nomore') {
						this.getShowList();
					}
				}else if (index === 1) {
					if(this.postAlbumList.length==0&&this.loadStatus2!='nomore') {
						this.getAlbumList();
					}
				}
			},
			async getUserInfo() {
				let res = await this.$api('homeUser')
				this.user = res.data.userInfo;
				uni.setNavigationBarTitle({
				　　title:this.user.nickname
				})
				this.loading = false;
			},
			async getShootList() {
				this.loadStatus1 = 'loading';
				let res = await this.$api('shoot')
				this.postShootList = this.postShootList.concat(res.data.list);
				if (this.page1 === res.data.total_pages || res.data.total_pages === 0) {
					this.loadStatus1 = 'nomore';
				} else {
					this.loadStatus1 = 'loadmore';
				}
			},
			async getAlbumList() {
				this.loadStatus2 = 'loading';
				let res = await this.$api('album')
				this.postAlbumList = this.postAlbumList.concat(res.data.list);
				if (this.page2 === res.data.total_pages || res.data.total_pages === 0) {
					this.loadStatus2 = 'nomore';
				} else {
					this.loadStatus2 = 'loadmore';
				}
			}		
		}
	}
</script>
<style>
	page {
		background-color: #f5f5f5;
	}
</style>
<style lang="scss" scoped>
	.myheader {
	    position: relative;
	    color: #fff;
	    height: 226rpx;
	    overflow: hidden;
	    font-size: 20rpx;
	    // background: -webkit-gradient(linear,left top,right top,color-stop(0,#EED146),to(#EED146));
	    // background: -webkit-linear-gradient(left,#EED146,#EED146);
	    // background: linear-gradient(90deg,#EED146,#EED146);
		background: #EED146;
	}
	// .myheader_edit, .myheader_help {
	//     position: absolute;
	//     background: url(https://img11.360buyimg.com/jdphoto/s164x150_jfs/t1/2681/22/2124/6628/5b961defE0ce6fd35/e11d45e2a5ab3517.png) -35px -5px/82px 75px no-repeat;
	//     width: 40rpx;
	//     height: 40rpx;
	//     right: 30rpx;
	//     top: 28rpx;
	//     z-index: 2;
	// }
	.myheader_opacity {
	    position: absolute;
	    display: block;
	    background: transparent;
	    width: 100%;
	    height: 100%;
	}
	.myheader_next {
	    position: relative;
	    background: #f7f7f7;
	    height: 208rpx;
	    overflow: hidden;
	    font-size: 20rpx;
	}
	.myheader_float {
	    position: absolute;
	    background: #fff;
	    border-radius: 16rpx;
	    height: 312rpx;
	    top: 100rpx;
	    left: 0;
	    right: 0;
	    bottom: 0;
	    margin: 0 30rpx;
	}
	.headepic {
	    z-index: 10;
	    width: 140rpx;
	    height: 140rpx;
	    border-radius: 16rpx;
	    top: -50rpx;
	    left: 30rpx;
	}
	.headepic, .myheader_piccontain {
	    position: relative;
	}
	.wqvue-image {
	    -webkit-transform: translateZ(0);
	    transform: translateZ(0);
	}
	.wqvue-image {
	    display: inline-block;
	    overflow: hidden;
	    position: relative;
	}
	.ll_fadeIn {
	    -webkit-transition: opacity .5s ease-in;
	    opacity: 0;
	    transition: opacity .5s ease-in;
	}
	.wqvue-image image {
	    width: 100%;
	    height: 100%;
	    position: absolute;
	    left: 50%;
	    top: 50%;
	    -webkit-transform: translate3d(-50%,-50%,0);
	    -moz-transform: translate3d(-50%,-50%,0);
	    -ms-transform: translate3d(-50%,-50%,0);
	    -o-transform: translate3d(-50%,-50%,0);
	    transform: translate3d(-50%,-50%,0);
	}
	.myheader_sex_conatin {
	    z-index: 10;
	    width: 40rpx;
	    height: 40rpx;
	    background-color: #fff;
	    position: absolute;
	    right: 76%;
	    padding: 4rpx;
	    left: 142rpx;
	    top: 62rpx;
	    border-radius: 8rpx 0 14rpx;
	    opacity: .8;
	}
	.myheader_sex_woman {
	    background-position: -160rpx -68rpx;
	}
	.myheader_level {
	    position: absolute;
	    z-index: 10;
	    font-size: 0;
	    height: 32rpx;
	    line-height: 34rpx;
	    background: -webkit-gradient(linear,left top,right top,from(#e2c460),to(#cfae68));
	    background: -webkit-linear-gradient(left,#e2c460,#cfae68);
	    background: linear-gradient(90deg,#e2c460,#cfae68);
	    margin-top: -48rpx;
	    margin-left: 30rpx;
	    border-radius: 20rpx;
	    color: #fff;
	    width: 140rpx;
	    overflow: hidden;
	    text-overflow: ellipsis;
	    white-space: nowrap;
	    text-align: center;
	    vertical-align: middle;
	    padding: 0 4rpx;
	}
	.myheaderlevelstart {
	    font-style: italic;
	    margin-right: 4rpx;
	    font-size: 20rpx;
	}
	.gradename {
	    font-size: 20rpx;
	}
	.myheader_info {
	    position: absolute;
	    left: 196rpx;
	    top: 20rpx;
	    overflow: hidden;
	}
	.myheader_name {
	    margin-bottom: 6rpx;
	}
	.myheader_name_text {
	    color: #333;
	    letter-spacing: 0;
	    display: inline-block;
	    max-width: 12em;
	    font-size: 28rpx;
	    vertical-align: middle;
	    overflow: hidden;
	    text-overflow: ellipsis;
	    white-space: nowrap;
	}
	.myheader_power {
		position: relative;
	    color: #999;
	}
	.myheaderline {
	    position: absolute;
	    background-color: #e6e6e6;
	    width: 2rpx;
	    top: 8rpx;
	    height: 20rpx;
	    margin-left: 10rpx;
	}
	.myheader_signature {
	    color: #999;
	    letter-spacing: 0;
	    line-height: 36rpx;
	    overflow: hidden;
	    text-overflow: ellipsis;
	    display: -webkit-box;
	    -webkit-line-clamp: 2;
	    -webkit-box-orient: vertical;
	    height: 72rpx;
	    margin-top: 10rpx;
	    margin-right: 120rpx;
	}
	.myheader_contactbtn {
		background-image: -webkit-linear-gradient(358deg,#8B2AEA,#A72BEA);
		background-image: linear-gradient(92deg,#8B2AEA,#A72BEA);
		border-radius: 200rpx;
		width: 138rpx;
		height: 50rpx;
		text-align: center;
		vertical-align: middle;
		color: #fff;
		font-size: 28rpx;
		letter-spacing: 0;
		line-height: 50rpx;
		display: inline-block;
		position: absolute;
		right: 170rpx;
		top: 112rpx;
	}
	.myheader_focusbtn {
	    background-image: -webkit-linear-gradient(358deg,#e93b3d,#f36535);
	    background-image: linear-gradient(92deg,#e93b3d,#f36535);
	    border-radius: 200rpx;
	    width: 108rpx;
	    height: 50rpx;
	    text-align: center;
	    vertical-align: middle;
	    color: #fff;
	    font-size: 28rpx;
	    letter-spacing: 0;
	    line-height: 50rpx;
	    display: inline-block;
	    position: absolute;
	    right: 40rpx;
	    top: 112rpx;
	}
	.myheader_tab {
	    position: relative;
	    width: 100%;
	    height: 98rpx;
	    display: -webkit-box;
	    display: -webkit-flex;
	    display: flex;
	    top: 56rpx;
	}
	.myheader_tabchild {
	    position: relative;
	    z-index: 1;
	    -webkit-flex: 1;
	    flex: 1;
	    -webkit-box-flex: 1;
	    text-align: center;
	}
	.myheadertabnum {
	    font-size: 32rpx;
	    color: #333;
	    text-align: center;
	    line-height: 42rpx;
	}
	.myheadertabname {
	    font-size: 24rpx;
	    color: #999;
	    text-align: center;
	    line-height: 36rpx;
	}
	.myheader_tabchild .line {
	    position: absolute;
	    background-color: #e6e6e6;
	    width: 2rpx;
	    top: 24rpx;
	    height: 20rpx;
	    right: -3%;
	}
	.tag-box {
		.tag{
			padding: 0rpx 10rpx;
			margin-right: 10rpx;
			border-radius: 5rpx;
			font-size: 22rpx;
			background-color: #f5f5f5;
			color: #616161;
		}
		
		.tag-guaranty {
			color: #ffffff;
			background-color: #24B19A;
		}
		
		.tag-cert {
			color: #ffffff;
			background-color: #5A84FB;
		}
	}
</style>
